package com.cd.form.jpa.repo;


import com.cd.form.jpa.domian.FormResult;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description create by JPA BUDDY
 * @Author lqq
 * @Date 2024/8/20 9:43
 **/
@Repository
public interface FormResultRepo extends JpaRepository<FormResult, Long> {

    List<FormResult> findByFormId(Long formId);

    List<FormResult> findByFormIdAndStatus(Long formId, Integer status);

    @Transactional
    @Modifying
    @Query("update FormResult f set f.status = ?1 where f.resultId = ?2")
    int updateStatusByResultId(Integer status, Long resultId);






    
}
